# 给定一个链表，删除重复的元素
# 极简：不需要额外变量来进行存储，和我自己写的额外变量进行存储区别不大：
def deleteDuplicates(self, head: ListNode) -> ListNode:
    current = head
    # 这个变量也太能省了吧
    while current != None and current.next != None:
        if current.next.val == current.val:
            current.next = current.next.next
        else:
            current = current.next
    return head


# 用变量存储之前的节点
def deleteDuplicates(self, head: ListNode) -> ListNode:
    if head == None: return head
    preNode = head
    curNode = preNode.next
    while curNode:
        preVal = preNode.val
        curVal = curNode.val    # 当前值
        if curVal == preVal:    # 相等
            preNode.next = curNode.next
        else:
            preNode = preNode.next
        curNode = curNode.next
    return head